home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekkan Dennou Club 147
/
Gekkan Dennou Club - 2000.8 Vol. 147 (Japan).7z
/
Gekkan Dennou Club - 2000.8 Vol. 147 (Japan) (Track 1).bin
/
fdimg
/
oh!.2hd
/
OH!DEN_B.LZH
/
TOOLS
/
CDC
/
ZCDCSRC.LZH
/
CDCBGM.C
< prev
next >
Wrap
Text File
|
1995-03-20
|
5KB
|
291 lines
#include <TNB.H>
struct CDC_TRACK_PTR {
short CDIN; // 0;NoCD 1;SetCD
int CDCMAX; // CDCの最大記憶数(以下,記憶数)
int TRKMAX; // CDの曲数
int ALLTIM; // CDの全演奏時間
int LISTFLAG; // CDCLISTにあったか -1ならあった
char CDNAME[40]; // CD名 40-1文字
UNchar EACHTRKDATA; // (記憶数)*40 各曲の名前 40-1文字
// (記憶数)*4 各曲の演奏時間+拡張曲名flag
// (記憶数)*4 各曲のスタート時間
};
void main(ar,av)
int ar;
char **av;
{
int i,j,c,m,n,f;
UNchar *s;
if ( ar==1 ){
B_PRINT(
"CDCBGM with CDC.x BGMモード演奏 Version 0.00 1995 TNB製作所 \r\n"
"\r\n"
"使用法:CDCBGM.x [file]|[T]|[[T/][AA:AA:AA][-[BB:BB:BB][,[CC:CC:CC][-[DD:DD:DD]]]]]\r\n"
"\r\n"
" T : T 曲目をBGMにします。\r\n"
" T/AA:AA:AA-BB:BB:BB : T 曲目の、AA分AA秒AA~BB分BB秒BBをBGMにします。\r\n"
" T/AA:AA:AA-BB:BB:BB,CC:CC:CC : T 曲目の、AA分AA秒AA~BB分BB秒BBを演奏後、\r\n"
" CC分CC秒CC~BB分BB秒BBをBGMにします。\r\n"
" T/AA:AA:AA-BB:BB:BB,CC:CC:CC-DD:DD:DD\r\n"
" : T 曲目の、AA分AA秒AA~BB分BB秒BBを演奏後、\r\n"
" CC分CC秒CC~DD分DD秒DDをBGMにします。\r\n"
"\r\n"
" file : ZCDC用の ZMSファイルかZMDファイル\r\n"
"\r\n"
);
return;
}
f=OPEN(av[1],0);
if ( f<0 ){
Disp(av[1]);
C_INKEY(0x52);
return;
}
for(;;){
s=Fgets(f);
if ( s<=0 )
break;
for(;;){
c=*s++;
if ( c==0 ) break;
if ( (c>=0x80 && c<=0x9f) || c>=0xE0 ){
s++;
continue;
}
if ( c=='C' && s[0]=='D' && (s[1]=='R'||s[1]=='C') && s[3]=='{' && s[4]=='[' ){
Disp(s+5);
C_INKEY(0x52);
break;
}
}
}
CLOSE(f);
}
/*+++++++++++++++++++++++++++++++++++++++*/
int Disp(s)
UNchar *s;
{
int i,j,aaa[4],ttt,mo,m,n;
struct CDC_TRACK_PTR *TP;
char *ss;
UNint *tl;
for(;*s==9||*s==' ';s++);
ss=s;
i=c_atoi(s,&j); s+=j;
for(;*s==9||*s==' ';s++);
ttt=0;
if ( *s=='/' ){
s++;
/*トラック単位*/
TP=C_TRACKS();
if ( i<1 || i>TP->TRKMAX )
return(0);
tl=(&(TP->EACHTRKDATA))+(TP->CDCMAX*40)+(TP->CDCMAX*4);
ttt=tl[i]&0xFFFFFF;
} elif ( *s==']' || *s==0 ){
/*BGMモード*/
C_BGM(i,0,0,0);
return(1);
} else {
s=ss;
}
for(;*s==9||*s==' ';s++);
for(m=0;m<4;aaa[m++]=0);
for(m=0;m<4;m++){
if ( *s==']' || *s==0 ) break;
if ( *s=='-' || *s==',' ){
s++;
if ( m==0 ) aaa[m]=ttt;
} else {
i=(s[0]-'0')*0x10000 *10+
(s[1]-'0')*0x10000 +
(s[3]-'0')*0x100 *10+
(s[4]-'0')*0x100 +
(s[6]-'0') *10+
(s[7]-'0');
s+=8;
aaa[m]=addtime( i,ttt );
for(;*s==9||*s==' ';s++);
if ( *s==']' || *s==0 ) break;
s++;
}
for(;*s==9||*s==' ';s++);
}
/*BGMモード*/
C_BGM(aaa[0],aaa[1],aaa[2],aaa[3]);
return(1);
}
/*************************************
時間 bcd 同志の足し算 t1+t2
**************************************/
int addtime( int t1,int t2 )
{
/* 00:mm:ss:xx 何分何秒何1/75秒 */
int t1m,t1s,t1u;
int t2m,t2s,t2u;
t1m=(t1>>16) & 0xff;
t1s=(t1>>8 ) & 0xff;
t1u=(t1 ) & 0xff;
t2m=(t2>>16) & 0xff;
t2s=(t2>>8 ) & 0xff;
t2u=(t2 ) & 0xff;
if ( (t1u+=t2u)>=75 ){
t1u-=75;
t1s++;
}
if ( (t1s+=t2s)>=60 ){
t1s-=60;
t1m++;
}
t1m+=t2m;
return( (t1m<<16)|(t1s<<8)|t1u );
}
/*++++++++++*/
int c_atoi(m,n)
UNchar *m;
int *n;
{
int i=0,j=0;
UNchar c;
for(;;){
if ( *m<'0' || *m>'9' )
break;
i=i*10+*m-'0';
m++;
j++;
}
if ( n!=0 ) *n=j; /*うごいたかず!!*/
return(i);
}
/*++++++++++*/
asm("
DOS macro callname
dc.w callname
endm
_SEEK equ $ff42
_READ equ $ff3f
.globl _Fgets
_Fgets: *------------------------------------------
* ファイルから1行をバッファに読み込み
* Fgets(f)
movea.l 4(sp),a2
move.w #1,-(sp)
move.l #0,-(sp)
move.w a2,-(sp)
DOS _SEEK
addq.l #8,sp
tst.l d0
bpl @f
moveq #-1,d0 *えらー
rts
@@:
move.l d0,d2 *シークポインタ
move.l #256,-(sp)
pea FgetsPTR(pc)
move.w a2,-(sp)
DOS _READ
lea 10(sp),sp
tst.l d0
bpl @f
moveq #-1,d0 *エラー
rts
@@:
bne @f
moveq #0,d0 *0;終了
rts
@@:
lea FgetsPTR(pc),a1
moveq #0,d1
_fgL2:
move.b (a1)+,d0
beq _fgL3
cmpi.b #$0d,d0
beq _fgL1_
cmpi.b #$0a,d0
beq _fgL1
cmpi.b #$80,d0 *全角
bcs @f
cmpi.b #$9F+1,d0
bcs _fgL4
@@: cmpi.b #$E0,d0
bcc _fgL4
addq.w #1,d1
cmpi.w #256,d1
bcc _fgL3
bra _fgL2
_fgL4:
move.b (a1)+,d0
addq.w #2,d1
cmpi.w #256,d1
bcc _fgL3
bra _fgL2
_fgL3:
clr.b (a1)
move.l #FgetsPTR,d0
rts
_fgL1_:
addq.w #1,d1
_fgL1:
addq.w #1,d1
move.b #0,-1(a1)
move.w #0,-(sp)
move.l d2,-(sp)
move.w a2,-(sp)
DOS _SEEK
move.w #1,-(sp)
move.l d1,-(sp)
move.w a2,-(sp)
DOS _SEEK
lea 16(sp),sp
move.l #FgetsPTR,d0
rts
FgetsPTR:
.ds.b 256 * 読み込み用バッファ
.dc.w 0
.even
.include CDC.MAC
_C_BGM:
movem.l d3-d4,-(sp)
move.l 4+8(sp),d1
move.l 8+8(sp),d2
move.l 12+8(sp),d3
move.l 16+8(sp),d4
CDC _CDC_BGM
movem.l (sp)+,d3-d4
rts
_C_PLAY:
move.l 4(sp),d1
move.l 8(sp),d2
CDC _CDC_PLAY
rts
_C_STOP:
CDC _CDC_STOP
rts
_C_INKEY:
move.l 4(sp),d1
CDC _CDC_INKEY
rts
_C_TRACKS:
CDC _CDC_TRACKS
rts
");